<template>
  <div id="index">
    <dv-full-screen-container class="bg" >
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <!-- 第一行 -->
        <div class="d-flex jc-center">
          <div class="fixheight"></div>
          <img src="../assets/header_img.png" alt="" class="headerImg">
        </div>

        <!-- 新修改主题框架 
        流年
        2025-01-01 星期六 2025年01月01日 -->

        <div class="body-box">
          <div class="left-content">
            <div>
                <centerLeft1 />
            </div>
            <div>
                <centerLeft2 />
            </div>
            <div>
                <centerLeft3 />
            </div>
            <div>
                <centerLeft4 />
            </div>
          </div>

        <div class="right-content">
            <div class="mapBox">
                <Map ref="mapComponent" @updateAlert="updateAlert"/>
            </div>
            <div class="d-flex">
                <div>
                    <centerRight1 @marker-selected="handleMarkerSelected" ref="centerRight1"/>
                </div>
                <div>
                    <centerRight2 @marker-selected="handleMarkerSelected" ref="centerRight2"/>
                </div>
                <div>
                    <centerRight3 />
                </div>
            </div>
        </div>
        </div>

        <!-- 底部 -->
        <div>
          <img src="../assets/bottom_img.png" alt="" style="width: 100%;">
        </div>

      </div>
    </dv-full-screen-container>

   
  </div>
</template>

<script>
import { formatTime } from "../utils/index.js";
import centerLeft1 from "./centerLeft1";
import centerLeft2 from "./centerLeft2";
import centerLeft3 from "./centerLeft3";
import centerLeft4 from "./centerLeft4";
import centerRight1 from "./centerRight1";
import centerRight2 from "./centerRight2";
import centerRight3 from "./centerRight3";
// 地图点位弹窗子组件
import Map from "./map/indextest";

export default {
  data() {
    return {
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      dialogTableVisible: false,
      dialogMapVisible: false,
    };
  },
  components: {
    centerLeft1,
    centerLeft2,
    centerLeft3,
    centerLeft4,
    centerRight1,
    centerRight2,
    centerRight3,
    Map,
  },
  mounted() {
    // this.timeFn();
    this.cancelLoading();
    // this.getInfo2()
  },
  methods: {
    timeFn() {
      setInterval(() => {
        this.dateDay = formatTime(new Date(), "HH: mm: ss");
        this.dateYear = formatTime(new Date(), "yyyy-MM-dd");
        this.dateWeek = this.weekday[new Date().getDay()];
      }, 1000);
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false;
      }, 500);
    },
    getInfo2() {
        this.$api.getInfo({}).then(res => {
          if(res.code == 0) {
            console.log('89898',res.data)
               
          }
        })
    },
    handleMarkerSelected(res) {
      console.log("markerId", res);
      if (this.$refs.mapComponent) {
        this.$refs.mapComponent.focusMarker(res.id,res.type);
      }
    },
    updateAlert(res) {
      if (this.$refs.centerRight1) {
        this.$refs.centerRight1.initData();
      }
      if (this.$refs.centerRight2) {
        this.$refs.centerRight2.initData();
      }
    },
  },
};
</script>

<style lang="scss">
@import "../assets/scss/index.scss";
</style>